package com.itheima.service.impl;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.mapper.StudentMapper;
import com.itheima.pojo.PageResult;
import com.itheima.pojo.Student;
import com.itheima.pojo.StudentQueryParam;
import com.itheima.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

@Service
public class StudentServiceImpl extends ServiceImpl<StudentMapper,Student> implements StudentService {

    @Autowired
    private StudentMapper studentMapper;

    @Override
    public PageResult selectAll(StudentQueryParam student) {
        List<Student> list = lambdaQuery().like(StringUtils.hasLength(student.getName()),s ->s.getName(),student.getName())
                .eq(student.getDegree() != null, student1 -> student1.getDegree(), student.getDegree())
                .list();

        return new PageResult(100L,list);
    }
}
